Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added NWB file example #342

Merged
merged 6 commits into from
Dec 22, 2022
Merged

Added NWB file example #342

merged 6 commits into from
Dec 22, 2022

Conversation

TheChymera
Copy link
Contributor

BIDS now supports NWB files, but there are no example datasets. This PR adds one.

@TheChymera
Copy link
Contributor Author

TheChymera commented Dec 8, 2022

Added actual NWB files in fbfce1f, created with:

import os
from uuid import uuid4
from datetime import datetime, timezone
from dateutil.tz import tzlocal, tzutc
import pynwb
from dandi.pynwb_utils import make_nwb_file, metadata_nwb_file_fields

def simple1_nwb_metadata():
    # very simple assignment with the same values as the key with 1 as suffix
    metadata = {f: f"{f}1" for f in metadata_nwb_file_fields}
    metadata["identifier"] = uuid4().hex
    # subject_fields

    # tune specific ones:
    # Needs an explicit time zone since otherwise pynwb would add one
    # But then comparison breaks anyways any ways yoh have tried to set it
    # for datetime.now.  Taking example from pynwb tests
    metadata["session_start_time"] = datetime(2017, 4, 15, 12, tzinfo=tzutc())
    metadata["keywords"] = ["keyword1", "keyword 2"]
    # since NWB 2.1.0 some fields values become "arrays" which are
    # then reloaded as tuples, so we force them being tuples here
    # See e.g. https://github.com/NeurodataWithoutBorders/pynwb/issues/1091
    for f in "related_publications", "experimenter":
        metadata[f] = (metadata[f],)
    return metadata

for i in os.listdir("."):
    if i.endswith("nwb"):
        b = simple1_nwb_metadata()
        a = make_nwb_file(
            i+"1",
            subject=pynwb.file.Subject(
                subject_id="01",
                date_of_birth=datetime(2016, 12, 1, tzinfo=tzutc()),
                sex="U",
                species="Mus musculus",
            ),
            **b,
        )
        print(a)

```
import os
from uuid import uuid4
from datetime import datetime, timezone
from dateutil.tz import tzlocal, tzutc
import pynwb
from dandi.pynwb_utils import make_nwb_file, metadata_nwb_file_fields

def simple1_nwb_metadata():
    # very simple assignment with the same values as the key with 1 as suffix
    metadata = {f: f"{f}1" for f in metadata_nwb_file_fields}
    metadata["identifier"] = uuid4().hex
    # subject_fields

    # tune specific ones:
    # Needs an explicit time zone since otherwise pynwb would add one
    # But then comparison breaks anyways any ways yoh have tried to set it
    # for datetime.now.  Taking example from pynwb tests
    metadata["session_start_time"] = datetime(2017, 4, 15, 12, tzinfo=tzutc())
    metadata["keywords"] = ["keyword1", "keyword 2"]
    # since NWB 2.1.0 some fields values become "arrays" which are
    # then reloaded as tuples, so we force them being tuples here
    # See e.g. NeurodataWithoutBorders/pynwb#1091
    for f in "related_publications", "experimenter":
        metadata[f] = (metadata[f],)
    return metadata

for i in os.listdir("."):
    if i.endswith("nwb"):
        b = simple1_nwb_metadata()
        a = make_nwb_file(
            i,
            subject=pynwb.file.Subject(
                subject_id="01",
                date_of_birth=datetime(2016, 12, 1, tzinfo=tzutc()),
                sex="U",
                species="Mus musculus",
            ),
            **b,
        )
        print(a)
```
ieeg_epilepsyNWB/README Outdated Show resolved Hide resolved
Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are still VHDR and VMRK files in this dataset, which are part of the BrainVision file format (usually together with an .eeg file) -- is this an accident or by design?

Also, could you please add this dataset to the README table in the root of the repo?

@TheChymera
Copy link
Contributor Author

TheChymera commented Dec 22, 2022

@sappelhoff As per email correspondence with Philippe Kahane of the University of Grenoble, dated 2022-12-09, we can release this without restrictive licensing. Olivier David has not replied for multiple weeks now. I would suggest proceeding and notifying again via email. We are not releasing any data which is not already in this repository, we are simply updating the licensing to permit what has already been done with this repo the entire time.

Comment:
As per email correspondence with Philippe Kahane of the University of
Grenoble, dated 2022-12-09, we can release this without restrictive
licensing. Olivier David has not replied for multiple weeks now. I would
suggest proceeding and notifying again via email. We are not releasing
any data which is not already in this repository, we are simply updating
the licensing to permit what has already been done with this repo the
entire time.
Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for going the extra mile and clarifying the situation @TheChymera

@sappelhoff sappelhoff merged commit 7c3e673 into bids-standard:master Dec 22, 2022
@TheChymera TheChymera deleted the nwb branch December 22, 2022 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants